"""
演示变量的注解类型
"""
import json
import random

#基础数据类型注解
# val_1: int = 1
# val_2: str = "nihao"
# val_3: bool = True
#类对象类型注解
class Student:
    pass
stu: Student = Student()


#基础容器类型注解
# my_list: list = [1, 2, 3]
# my_tupel: tuple = (1, 2, 3)
# my_dict: dict = {"itheima": 666}
#容器类型详细注解
my_list: list[int] = [1, 2, 3]
my_tupel: tuple[int,str,bool] = (1, "2", True)
my_dict: dict[str,int] = {"itheima": 666}

#在注释中进行类型注解
val_1 = random.randint(1,10)    #type: int
#在字符串中包含了引号最外面标识字符串的引号,就要用不一样的类型的
val_2 = json.loads('{"name":"张三"}')         #type: dict[str,str]
def func():
    pass
var_3 = func()  #type: int
#类型注解的限制
# val_4: int = "itheima"
# val_5: str = 53
#这样也不会报错

"""
总结:一般无法直接看出来的变量类型,就需要添加类型注解
"""